Imports System
Imports System.Collections.Generic
Imports System.Windows.Forms
Imports SoftwareLocker
Imports VirtualDesk.MainLic
Imports System.Xml
Imports System.IO
Namespace My

    ' The following events are availble for MyApplication:
    ' 
    ' Startup: Raised when the application starts, before the startup form is created.
    ' Shutdown: Raised after all application forms are closed.  This event is not raised if the application terminates abnormally.
    ' UnhandledException: Raised if the application encounters an unhandled exception.
    ' StartupNextInstance: Raised when launching a single-instance application and the application is already active. 
    ' NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected.
    Partial Friend Class MyApplication
        Public Function CheckAppSettings(ByVal KeyName As String, ByVal KeyValue As String)

            '  AppDomain.CurrentDomain.SetupInformation.ConfigurationFile 
            ' This will get the app.config file path from Current application Domain
            Dim XmlDoc As New XmlDocument()
            ' Load XML Document
            XmlDoc.Load(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile)
            ' Navigate Each xml Element of app.Config file
            For Each xElement As XmlElement In XmlDoc.DocumentElement
                If xElement.Name = "appSettings" Then
                    ' Loop each node of appSettings Element 
                    ' xNode.Attributes(0).Value , Mean First Attributes of Node , KeyName Portion
                    ' xNode.Attributes(1).Value , Mean Second Attributes of Node,KeyValue Portion
                    For Each xNode As XmlNode In xElement.ChildNodes
                        If xNode.Attributes(0).Value = KeyName Then
                            If xNode.Attributes(1).Value = KeyValue Then
                                Dim frmInit As New FrmInitialSetup
                                If frmInit.ShowDialog() = DialogResult.No Then
                                    End
                                End If

                            End If
                        End If
                    Next
                End If
            Next
            ' Save app.config file
            ''XmlDoc.Save(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile)
            Return True

        End Function
        Private Sub MyApplication_Startup(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles Me.Startup
            CheckAppSettings("Configure", "True")
           

        End Sub
    End Class

End Namespace

